import request from '@/router/axios'
import { getToken } from '@/util/auth';
import website from '@/config/website';
import {Base64} from "js-base64";
import {bserialize} from '@/util/util'
// 详情接口
export const detailList = (query) => {
  return request({
    // url: 'http://192.168.2.11:8107/order/detail',
    url: '/api/xmbz-order/order/detail',
    method: 'get',
    params: query
  })
}

// 查询接口
export const orderRefundMarkList = (query) => {
  return request({
    url: '/api/xmbz-order/order/orderRefundMarkList',
    // url: 'http://192.168.2.11:8107/order/list',
    method: 'get',
    params: query
  })
}
export const orderList = (query) => {
  return request({
    url: '/api/xmbz-order/order/list',
    // url: 'http://192.168.2.11:8107/order/list',
    method: 'get',
    params: query
  })
}

export const orderWaitList = (query) => {
  return request({
    url: '/api/xmbz-order/orderWait/list',
    method: 'get',
    params: query
  })
}

export const updateList = (data) => {
  return request({
    // url: 'http://192.168.2.11:8107/order/update',
    url: '/api/xmbz-order/order/update',
    method: 'post',
    data,
    isLoading: true
  })
}

export const refundUnsubscribeConfirmOrder = (data) => {
  return request({
    // url: 'http://192.168.2.11:8107/order/refundUnsubscribeConfirmOrder',
    url: '/api/xmbz-order/order/refundUnsubscribeConfirmOrder',
    method: 'post',
    data,
    isLoading: true
  })
}

// 修改后请求订单状态接口
export const updateByProvisions = (data) => {
  return request({
    // url: 'http://192.168.2.11:8107/order/updateByProvisions',
    url: '/api/xmbz-order/order/updateByProvisions',
    method: 'POST',
    data
  })
}

// export const orderList = (query) => {
//   return request({
//     url: 'http://192.168.2.106:8107/order/list',
//     method: 'get',
//     params: query
//   })
// }

export const shopSize = (query) => {
  return request({
    url: '/api/xmbz-order/goods/detail',
    method: 'get',
    params: query
  })
}

// // 订单状态列表
// export const statusList = (query) => {
//   return request({
//     url: 'http://192.168.2.106:8107/order/status/list',
//     method: 'get',
//     params: query
//   })
// }

// 催单类型列表(催单)
export const getReminderTypeList = (query) => {
  return request({
    url: '/api/xmbz-work/work/getReminderTypeList',
    method: 'get',
    params: query
  })
}

// 新增催单(催单)
export const addWorkOrderReminder = (query) => {
  return request({
    url: '/api/xmbz-work/work/addWorkOrderReminder',
    method: 'post',
    params: query
  })
}

// 责任部门(备款)
export const getResponsibleDepartmentList = (query) => {
  return request({
    url: '/api/xmbz-work/work/getResponsibleDepartmentList',
    method: 'get',
    params: query
  })
}

// 蛋糕去向(备款)
export const getCakeWhereaboutsList = (query) => {
  return request({
    url: '/api/xmbz-work/work/getCakeWhereaboutsList',
    method: 'get',
    params: query
  })
}

// 备款来源(备款)
export const getProvisionsOperationList = (query) => {
  return request({
    url: '/api/xmbz-work/work/getProvisionsOperationList',
    method: 'get',
    params: query
  })
}

// 开始修改
export const startUpdate = (query) => {
  return request({
    url: '/api/xmbz-order/order/startUpdate',
    // url: 'http://192.168.0.122:8107/order/startUpdate',
    method: 'get',
    params: query
  })
}

// 强制解锁
export const forceUnlock = (query) => {
  return request({
    url: '/api/xmbz-order/order/forceUnlock',
    method: 'get',
    params: query
  })
}

// 强制解锁
export const unlockOrder = (query) => {
  return request({
    url: '/api/xmbz-order/order/unlock',
    method: 'get',
    params: query
  })
}

// 新增备款（选择退订、选择改期）
export const addWorkOrderProvisions = (data) => {
  return request({
    url: '/api/xmbz-work/work/addWorkOrderProvisions',
    // url:'http://192.168.2.106:8112/work/addWorkOrderProvisions',
    method: 'post',
    data
  })
}

// 退订原因列表
export const getUnsubscribeReasonList = (query) => {
  return request({
    url: '/api/xmbz-work/work/getUnsubscribeReasonList',
    method: 'get',
    params: query
  })
}

// 是否生产列表
export const getIsProductionList = (query) => {
  return request({
    url: '/api/xmbz-work/work/getIsProductionList',
    method: 'get',
    params: query
  })
}

// 新增退订
export const addWorkOrderUnsubscribe = (data) => {
  return request({
    url: '/api/xmbz-work/work/addWorkOrderUnsubscribe',
    // url:'http://192.168.2.11:8112/work/addWorkOrderUnsubscribe',
    method: 'post',
    data
  })
}

// 退款等级列表
export const getRefundGradeList = (query) => {
  return request({
    url: '/api/xmbz-work/work/getRefundGradeList',
    method: 'get',
    params: query
  })
}

// 退款原因列表
export const getRefundReasonList = (query) => {
  return request({
    url: '/api/xmbz-work/work/getRefundReasonList',
    method: 'get',
    params: query
  })
}

// 退款类型列表
export const getRefundTypeList = (query) => {
  return request({
    url: '/api/xmbz-work/work/getRefundTypeList',
    method: 'get',
    params: query
  })
}

// 退款类型列表
export const getRefundTypeReasonList = (query) => {
  return request({
    url: '/api/xmbz-work/work/getRefundTypeReasonList',
    method: 'get',
    params: query
  })
}

// 全额退款列表
export const getFullRefundList = (query) => {
  return request({
    url: '/api/xmbz-work/work/getFullRefundList',
    method: 'get',
    params: query
  })
}

// 赔偿方式列表
export const getCompensationMethodList = (query) => {
  return request({
    url: '/api/xmbz-work/work/getCompensationMethodList',
    // url: 'http://192.168.2.106:8112/work/getCompensationMethodList',
    method: 'get',
    params: query
  })
}

// 退款方式列表(取dictKey)
export const getRefundModeList = (query) => {
  return request({
    url: '/api/xmbz-work/work/getRefundModeList',
    // url: 'http://192.168.2.106:8112/work/getRefundModeList',
    method: 'get',
    params: query
  })
}

// 新增退款
export const addWorkOrderRefund = (data) => {
  return request({
    url: '/api/xmbz-work/work/addWorkOrderRefund',
    // url: 'http://192.168.2.106:8112/work/addWorkOrderRefund',
    method: 'post',
    data
  })
}

// 退款不退货
export const addRefundNotReturn = (data) => {
  return request({
    url: '/api/xmbz-work/work/addRefundNotReturn',
    // url: 'http://192.168.2.11:8112/work/addRefundNotReturn',
    method: 'post',
    data
  })
}

// 恢复订单
export const getRecoveryOrder = (query) => {
  return request({
    url: '/api/xmbz-work/work/getRecoveryOrder',
    method: 'post',
    params: query
  })
}

// 投诉等级列表
export const getComplaintLevelList = (query) => {
  return request({
    url: '/api/xmbz-work/work/getComplaintLevelList',
    method: 'get',
    params: query
  })
}

// 投诉渠道列表
export const getComplaintChannelList = (query) => {
  return request({
    url: '/api/xmbz-work/work/getComplaintChannelList',
    method: 'get',
    params: query
  })
}

// 新增投诉
export const addWorkOrderComplaint = (data) => {
  return request({
    url: '/api/xmbz-work/work/addWorkOrderComplaint',
    method: 'post',
    header: 'application/json;charset=utf-8',
    data
  })
}

// 日志列表
export const getOrderOperateLog = (query) => {
  return request({
    url: '/api/xmbz-work/work/getOrderOperateLog',
    method: 'get',
    params: query
  })
}

// 待处理接口
export const proList = (query) => {
  return request({
    url: '/api/xmbz-order/order/pending',
    // url: 'http://192.168.2.106:8107/order/pending',
    method: 'get',
    params: query
  })
}

// 订单状态列表
export const statusList = (query) => {
  return request({
    url: '/api/xmbz-order/order/status/list',
    // url: 'http://192.168.2.106:8107/order/status/list',
    method: 'get',
    params: query
  })
}

// 获取只显示城市的部门树形结构
export const getDeptCityTree = (query) => {
  return request({
    url: '/api/xmbz-system/dept/getDeptCityTree',
    // url: 'http://192.168.2.106:8108/dept/getDeptCityTree',
    method: 'get',
    params: query
  })
}

// 根据分仓名称和城市id查询仓库id
export const getWarehouseId = (query) => {
  return request({
    url: '/api/xmbz-order/warehouse/getWarehouseId',
    // url: 'http://192.168.2.106:8107/warehouse/getWarehouseId',
    method: 'get',
    params: query
  })
}

// 根据分仓名称和城市id查询仓库id
export const getCategories = (query) => {
  return request({
    url: '/api/xmbz-goods/goods/getCategories',
    // url: 'http://192.168.2.106:8107/goods/getCategories',
    method: 'get',
    params: query
  })
}

// 获取订单短信列表
export const smsPage = (query) => {
  return request({
    url: '/api/xmbz-order/order/sms/smsPage',
    // url: 'http://192.168.0.191:8107/order/sms/smsPage',
    method: 'get',
    params: query
  })
}

// 短信列表重发
export const retry = (query) => {
  return request({
    url: '/api/xmbz-order/order/sms/retry',
    // url: 'http://192.168.0.191:8107/order/sms/retry',
    method: 'post',
    params: query
  })
}

// 根据订单号,查询商品列表(退款)
export const getGoodsByOrderId = (query) => {
  return request({
    url: '/api/xmbz-work/work/getGoodsByOrderId',
    method: 'get',
    params: query
  })
}


// 平台退款中
export const deleteOrderExt = (data) => {
  return request({
    url: '/api/xmbz-order/order/deleteOrderExt',
    // url: 'http://192.168.0.191:8107/order/deleteOrderExt',
    method: 'post',
    data
  })
}

// 添加订单操作日志
export const add0rderOperateLog = (query) => {
  return request({
    url: '/api/xmbz-order/order/add0rderOperateLog',
    // url: 'http://192.168.2.11:8107/order/add0rderOperateLog',
    method: 'post',
    params: query
  })
}

// 编辑订单里面商品的提交时间
export const orderSubmitGoodsTime = (query) => {
  return request({
    url: '/api/xmbz-order/order/orderSubmitGoodsTime',
    // url: 'http://192.168.2.11:8107/order/orderSubmitGoodsTime',
    method: 'post',
    params: query
  })
}

// 根据订单号,查询商品列表(退款)
export const getWarehouseListByCityId = (query) => {
  return request({
    url: '/api/xmbz-order/warehouse/getWarehouseListByCityId',
    method: 'get',
    params: query
  })
}

// 获取标签
export const getOrderLabels = (query) => {
  return request({
    url: '/api/xmbz-order/order/getOrderLabels',
    method: 'get',
    params: query
  })
}
// 根据订单id获取标签
export const getOrderLabelsByOrderId = (query) => {
  return request({
    url: '/api/xmbz-order/order/getOrderLabelsByOrderId',
    method: 'get',
    params: query
  })
}

// 保存订单标签
export const saveOrderLabels = (query) => {
  return request({
    url: '/api/xmbz-order/order/saveOrderLabels',
    method: 'post',
    params: query
  })
}

// 改仓退订
export const clientAddWorkOrderUnsubscribe = (data) => {
  return request({
    url: '/api/xmbz-order/order/clientAddWorkOrderUnsubscribe',
    method: 'post',
    data
  })
}

// 验证跨仓是否需要建新单
export const validateOrder = (data) => {
  return request({
    url: '/api/xmbz-order/order/validateOrder',
    method: 'post',
    data
  })
}

// 获取分仓列表
export const getWarehouseListCityIds = (query) => {
  return request({
    url: '/api/xmbz-order/warehouse/getWarehouseListCityIds',
    method: 'get',
    params: query
  })
}

// 搭售商品
export const listTyingSaleProducts = (query) => {
  return request({
    url: '/api/xmbz-work/work/listTyingSaleProducts',
    method: 'get',
    params: query
  })
}

// 查询是否未处理客户修改的订单
export const getCustomChange = (params) => {
  return request({
    url: '/api/xmbz-order/explain/getCustomChange',
    method: 'get',
    params
  })
}

// 处理客户修改的订单
export const disposeCustomChange = (data) => {
  return request({
    url: '/api/xmbz-order/explain/disposeCustomChange',
    method: 'post',
    data
  })
}

// 校验是否异常补单
export const validateReplacementOrder = (query) => {
  return request({
    url: '/api/xmbz-work/work/validateReplacementOrder',
    method: 'get',
    params: query
  })
}

// 再次发起退款
export const updateRefundPrice = (data) => {
  return request({
    url: '/api/xmbz-work/work/updateRefundPrice',
    method: 'post',
    data
  })
}

// 订单列表
export const listOrders = (params) => {
  return request({
    url: '/api/xmbz-order/qiyu/open/listOrders',
    method: 'get',
    params
  })
}
